<template>
<div class="field myfield">
    <field_title :title_show="!field.hideTitle&&!field.no_title" :field="field" ></field_title>
  <!-- <p class='ui text' v-if='$store.state.isDetail'>{{val}}</p> -->
  <div class="ui  info attached message" v-if='$store.state.isDetail'>
    <p>{{val}}</p>
  </div>
  <input v-else type="text" v-validate="field.valid||{}" :data-vv-as="field.title" v-model.trim="val" :name="field.name" @keyup.enter.stop.prevent="onEnter" :placeholder="placeholder">
  <!--<errmsg  v-show="errors.has(field.name)">-->
    <!--{{ errors.first(field.name) }}-->
  <!--</errmsg>-->
</div>
</template>

<script>
import tool from 'src/util/tool';
import util from '_util/index';

import errmsg from 'components/valid/errmsg';
import field_title from 'components/field/com/field_title';
const store=util.store

export default {
  data() {
    return {
      val: '',
    }
  },
  components:{errmsg,field_title},
  methods: {
      onEnter(){
          this.$emit('onEnter');
      }
  },
  watch: {
    val: function(val, old) {
      if (val != old) {
        this.$emit('setVo', this.field.name, val)
      }
    },
    hasError: function(val, old) {
//      store.push(this,'setVoError','voErrors', this.field.name, this.errors.first(this.field.name))
    }
  },
  computed: {
    placeholder() {
      return `请输入${this.field.title}`
    },
//    hasError(){
//      return this.errors.has(this.field.name)
//    }
  },
  props: ['field','param'],
  created() {
    this.val=this.field.fval
  },
  mounted() {
  }
};
</script>

<style scoped>
.field {}
</style>
